{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7ecc7207",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T06:26:57.624743Z",
     "start_time": "2021-11-12T06:26:55.979763Z"
    }
   },
   "outputs": [],
   "source": [
    "from autogluon.tabular import TabularDataset, TabularPredictor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4a392ef1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T06:26:58.867066Z",
     "start_time": "2021-11-12T06:26:58.846123Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['stores.csv', 'train.csv', 'features.csv', 'test.csv', 'sampleSubmission.csv']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.listdir('../data/walmart_recruiting')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6bc8546b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T06:27:02.130009Z",
     "start_time": "2021-11-12T06:27:01.886881Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_data = TabularDataset('../data/walmart_recruiting/train.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "21370fd8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T06:27:02.681137Z",
     "start_time": "2021-11-12T06:27:02.674837Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(421570, 5)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4ba99057",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T06:27:03.663555Z",
     "start_time": "2021-11-12T06:27:03.642099Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Store</th>\n",
       "      <th>Dept</th>\n",
       "      <th>Date</th>\n",
       "      <th>Weekly_Sales</th>\n",
       "      <th>IsHoliday</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2010-02-05</td>\n",
       "      <td>24924.50</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2010-02-12</td>\n",
       "      <td>46039.49</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2010-02-19</td>\n",
       "      <td>41595.55</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2010-02-26</td>\n",
       "      <td>19403.54</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2010-03-05</td>\n",
       "      <td>21827.90</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Store  Dept        Date  Weekly_Sales  IsHoliday\n",
       "0      1     1  2010-02-05      24924.50      False\n",
       "1      1     1  2010-02-12      46039.49       True\n",
       "2      1     1  2010-02-19      41595.55      False\n",
       "3      1     1  2010-02-26      19403.54      False\n",
       "4      1     1  2010-03-05      21827.90      False"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ec3eacc4",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T06:27:08.032314Z",
     "start_time": "2021-11-12T06:27:08.027644Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    }
   ],
   "source": [
    "label = 'Weekly_Sales'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "a225cdb6",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:28:56.792439Z",
     "start_time": "2021-11-12T06:27:13.784982Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Warning: Training may take a very long time because `time_limit` was not specified and `train_data` is large (421570 samples, 38.78 MB).\n",
      "\tConsider setting `time_limit` to ensure training finishes within an expected duration or experiment with a small portion of `train_data` to identify an ideal `presets` and `hyperparameters` configuration.\n",
      "Beginning AutoGluon training ...\n",
      "AutoGluon will save models to \"agModels-kaggle_walmart_recruiting/\"\n",
      "AutoGluon Version:  0.2.1b20210716\n",
      "Train Data Rows:    421570\n",
      "Train Data Columns: 4\n",
      "Preprocessing data ...\n",
      "AutoGluon infers your prediction problem is: 'regression' (because dtype of label-column == float and many unique label-values observed).\n",
      "\tLabel info (max, min, mean, stddev): (693099.36, -4988.94, 15981.25812, 22711.18352)\n",
      "\tIf 'regression' is not the correct problem_type, please manually specify the problem_type argument in fit() (You may specify problem_type as one of: ['binary', 'multiclass', 'regression'])\n",
      "Using Feature Generators to preprocess the data ...\n",
      "Fitting AutoMLPipelineFeatureGenerator...\n",
      "\tAvailable Memory:                    263026.04 MB\n",
      "\tTrain Data (Original)  Memory Usage: 35.41 MB (0.0% of available memory)\n",
      "\tInferring data type of each feature based on column values. Set feature_metadata_in to manually specify special dtypes of the features.\n",
      "\tStage 1 Generators:\n",
      "\t\tFitting AsTypeFeatureGenerator...\n",
      "\tStage 2 Generators:\n",
      "\t\tFitting FillNaFeatureGenerator...\n",
      "\tStage 3 Generators:\n",
      "\t\tFitting IdentityFeatureGenerator...\n",
      "\t\tFitting CategoryFeatureGenerator...\n",
      "\t\t\tFitting CategoryMemoryMinimizeFeatureGenerator...\n",
      "\t\tFitting DatetimeFeatureGenerator...\n",
      "\tStage 4 Generators:\n",
      "\t\tFitting DropUniqueFeatureGenerator...\n",
      "\tTypes of features in original data (raw dtype, special dtypes):\n",
      "\t\t('bool', [])                       : 1 | ['IsHoliday']\n",
      "\t\t('int', [])                        : 2 | ['Store', 'Dept']\n",
      "\t\t('object', ['datetime_as_object']) : 1 | ['Date']\n",
      "\tTypes of features in processed data (raw dtype, special dtypes):\n",
      "\t\t('category', [])             : 1 | ['IsHoliday']\n",
      "\t\t('int', [])                  : 2 | ['Store', 'Dept']\n",
      "\t\t('int', ['datetime_as_int']) : 1 | ['Date']\n",
      "\t0.9s = Fit runtime\n",
      "\t4 features in original data used to generate 4 features in processed data.\n",
      "\tTrain Data (Processed) Memory Usage: 10.54 MB (0.0% of available memory)\n",
      "Data preprocessing and feature engineering runtime = 1.04s ...\n",
      "AutoGluon will gauge predictive performance using evaluation metric: 'root_mean_squared_error'\n",
      "\tTo change this, specify the eval_metric argument of fit()\n",
      "Automatically generating train/validation split with holdout_frac=0.01, Train Rows: 417354, Val Rows: 4216\n",
      "Fitting 11 L1 models ...\n",
      "Fitting model: KNeighborsUnif ...\n",
      "\t-6480.8374\t = Validation root_mean_squared_error score\n",
      "\t1.0s\t = Training runtime\n",
      "\t0.11s\t = Validation runtime\n",
      "Fitting model: KNeighborsDist ...\n",
      "\t-6480.743\t = Validation root_mean_squared_error score\n",
      "\t1.03s\t = Training runtime\n",
      "\t0.11s\t = Validation runtime\n",
      "Fitting model: LightGBMXT ...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1000]\ttrain_set's rmse: 14150.7\tvalid_set's rmse: 14053\n",
      "[2000]\ttrain_set's rmse: 12268\tvalid_set's rmse: 12243.5\n",
      "[3000]\ttrain_set's rmse: 11213.7\tvalid_set's rmse: 11225.5\n",
      "[4000]\ttrain_set's rmse: 10592.7\tvalid_set's rmse: 10625.2\n",
      "[5000]\ttrain_set's rmse: 10150.2\tvalid_set's rmse: 10188.5\n",
      "[6000]\ttrain_set's rmse: 9827.37\tvalid_set's rmse: 9889.16\n",
      "[7000]\ttrain_set's rmse: 9575.01\tvalid_set's rmse: 9648.05\n",
      "[8000]\ttrain_set's rmse: 9394.64\tvalid_set's rmse: 9473.85\n",
      "[9000]\ttrain_set's rmse: 9221.51\tvalid_set's rmse: 9310.15\n",
      "[10000]\ttrain_set's rmse: 9079.84\tvalid_set's rmse: 9172.87\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\t-9172.8662\t = Validation root_mean_squared_error score\n",
      "\t3704.91s\t = Training runtime\n",
      "\t0.52s\t = Validation runtime\n",
      "Fitting model: LightGBM ...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1000]\ttrain_set's rmse: 5579.55\tvalid_set's rmse: 5466.71\n",
      "[2000]\ttrain_set's rmse: 4629.26\tvalid_set's rmse: 4543.68\n",
      "[3000]\ttrain_set's rmse: 4141.82\tvalid_set's rmse: 4118.47\n",
      "[4000]\ttrain_set's rmse: 3845.32\tvalid_set's rmse: 3870.75\n",
      "[5000]\ttrain_set's rmse: 3636.24\tvalid_set's rmse: 3691.64\n",
      "[6000]\ttrain_set's rmse: 3501.14\tvalid_set's rmse: 3568.65\n",
      "[7000]\ttrain_set's rmse: 3388.37\tvalid_set's rmse: 3489.86\n",
      "[8000]\ttrain_set's rmse: 3286.83\tvalid_set's rmse: 3411.44\n",
      "[9000]\ttrain_set's rmse: 3210.97\tvalid_set's rmse: 3364.89\n",
      "[10000]\ttrain_set's rmse: 3146.4\tvalid_set's rmse: 3328.92\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\t-3328.8901\t = Validation root_mean_squared_error score\n",
      "\t2876.26s\t = Training runtime\n",
      "\t0.18s\t = Validation runtime\n",
      "Fitting model: RandomForestMSE ...\n",
      "\t-4024.4759\t = Validation root_mean_squared_error score\n",
      "\t13.58s\t = Training runtime\n",
      "\t0.22s\t = Validation runtime\n",
      "Fitting model: CatBoost ...\n",
      "\t-5647.3601\t = Validation root_mean_squared_error score\n",
      "\t60.55s\t = Training runtime\n",
      "\t0.03s\t = Validation runtime\n",
      "Fitting model: ExtraTreesMSE ...\n",
      "\t-3919.1001\t = Validation root_mean_squared_error score\n",
      "\t8.82s\t = Training runtime\n",
      "\t0.32s\t = Validation runtime\n",
      "Fitting model: NeuralNetFastAI ...\n",
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/tables/__init__.py:99: DeprecationWarning: `np.typeDict` is a deprecated alias for `np.sctypeDict`.\n",
      "  from .utilsextension import (\n",
      "\t-18176.5324\t = Validation root_mean_squared_error score\n",
      "\t448.25s\t = Training runtime\n",
      "\t0.11s\t = Validation runtime\n",
      "Fitting model: XGBoost ...\n",
      "\tWarning: Exception caused XGBoost to fail during training (ImportError)... Skipping this model.\n",
      "\t\tcannot import name 'EarlyStopping' from 'xgboost.callback' (/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/xgboost/callback.py)\n",
      "Fitting model: NeuralNetMXNet ...\n",
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/h5py/__init__.py:46: DeprecationWarning: `np.typeDict` is a deprecated alias for `np.sctypeDict`.\n",
      "  from ._conv import register_converters as _register_converters\n",
      "\tWarning: Exception caused NeuralNetMXNet to fail during training... Skipping this model.\n",
      "\t\tLegacy mxnet==1.4.0 detected, some new modules will not work properly. mxnet>=1.6.0 is required. You can use pip to upgrade mxnet `pip install mxnet --upgrade` or `pip install mxnet_cu101 --upgrade`\n",
      "Detailed Traceback:\n",
      "Traceback (most recent call last):\n",
      "  File \"/mnt/disk0/home/caihengxing/software/autogluon-master/tabular/src/autogluon/tabular/trainer/abstract_trainer.py\", line 960, in _train_and_save\n",
      "    model = self._train_single(X, y, model, X_val, y_val, **model_fit_kwargs)\n",
      "  File \"/mnt/disk0/home/caihengxing/software/autogluon-master/tabular/src/autogluon/tabular/trainer/abstract_trainer.py\", line 932, in _train_single\n",
      "    model = model.fit(X=X, y=y, X_val=X_val, y_val=y_val, **model_fit_kwargs)\n",
      "  File \"/mnt/disk0/home/caihengxing/software/autogluon-master/core/src/autogluon/core/models/abstract/abstract_model.py\", line 518, in fit\n",
      "    out = self._fit(**kwargs)\n",
      "  File \"/mnt/disk0/home/caihengxing/software/autogluon-master/tabular/src/autogluon/tabular/models/tabular_nn/tabular_nn_model.py\", line 168, in _fit\n",
      "    try_import_mxnet()\n",
      "  File \"/mnt/disk0/home/caihengxing/software/autogluon-master/core/src/autogluon/core/utils/try_import.py\", line 40, in try_import_mxnet\n",
      "    raise ValueError(msg)\n",
      "ValueError: Legacy mxnet==1.4.0 detected, some new modules will not work properly. mxnet>=1.6.0 is required. You can use pip to upgrade mxnet `pip install mxnet --upgrade` or `pip install mxnet_cu101 --upgrade`\n",
      "Fitting model: LightGBMLarge ...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1000]\ttrain_set's rmse: 3851.26\tvalid_set's rmse: 4022.61\n",
      "[2000]\ttrain_set's rmse: 3154\tvalid_set's rmse: 3469.87\n",
      "[3000]\ttrain_set's rmse: 2791.93\tvalid_set's rmse: 3256.69\n",
      "[4000]\ttrain_set's rmse: 2568.63\tvalid_set's rmse: 3138.98\n",
      "[5000]\ttrain_set's rmse: 2401.48\tvalid_set's rmse: 3072.12\n",
      "[6000]\ttrain_set's rmse: 2259.02\tvalid_set's rmse: 3025.76\n",
      "[7000]\ttrain_set's rmse: 2142.01\tvalid_set's rmse: 2976.31\n",
      "[8000]\ttrain_set's rmse: 2056.1\tvalid_set's rmse: 2946.14\n",
      "[9000]\ttrain_set's rmse: 1989.29\tvalid_set's rmse: 2923.93\n",
      "[10000]\ttrain_set's rmse: 1924.52\tvalid_set's rmse: 2908.25\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\t-2908.1992\t = Validation root_mean_squared_error score\n",
      "\t122.05s\t = Training runtime\n",
      "\t0.15s\t = Validation runtime\n",
      "Fitting model: WeightedEnsemble_L2 ...\n",
      "\t-2883.5311\t = Validation root_mean_squared_error score\n",
      "\t0.56s\t = Training runtime\n",
      "\t0.0s\t = Validation runtime\n",
      "AutoGluon training complete, total runtime = 7302.95s ...\n",
      "TabularPredictor saved. To load, use: predictor = TabularPredictor.load(\"agModels-kaggle_walmart_recruiting/\")\n"
     ]
    }
   ],
   "source": [
    "save_path = 'agModels-kaggle_walmart_recruiting'  # specifies folder to store trained models\n",
    "predictor = TabularPredictor(label=label, path=save_path).fit(train_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "fa84c4eb",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:28:56.829037Z",
     "start_time": "2021-11-12T08:28:56.794587Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n",
      "Loaded data from: ../data/walmart_recruiting/test.csv | Columns = 4 / 4 | Rows = 115064 -> 115064\n"
     ]
    }
   ],
   "source": [
    "test_data_nolab = TabularDataset('../data/walmart_recruiting/test.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "54cce4ce",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:29:15.721126Z",
     "start_time": "2021-11-12T08:28:56.831477Z"
    }
   },
   "outputs": [],
   "source": [
    "y_pred = predictor.predict(test_data_nolab)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ca6cc9bf",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:29:15.731782Z",
     "start_time": "2021-11-12T08:29:15.723760Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0         28005.693359\n",
       "1         28005.693359\n",
       "2         28005.693359\n",
       "3         28776.363281\n",
       "4         28005.693359\n",
       "              ...     \n",
       "115059     1834.732300\n",
       "115060     1834.732300\n",
       "115061     1834.732300\n",
       "115062     1834.732300\n",
       "115063     1834.732300\n",
       "Name: Weekly_Sales, Length: 115064, dtype: float32"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "240cd16c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:29:15.736449Z",
     "start_time": "2021-11-12T08:29:15.733808Z"
    }
   },
   "outputs": [],
   "source": [
    "id_ = ['Id']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "b4fd354e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:46:25.529555Z",
     "start_time": "2021-11-12T08:46:25.476977Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    }
   ],
   "source": [
    "sub = test_data_nolab[['Store', 'Dept','Date']].copy()\n",
    "sub[label] = list(y_pred.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c91a1d6c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:46:42.300172Z",
     "start_time": "2021-11-12T08:46:42.051449Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    }
   ],
   "source": [
    "def cols_concat(df, con_list):\n",
    "    name = \"__\".join(con_list)\n",
    "    df[name] = df[con_list[0]].astype(str)\n",
    "    for item in con_list[1:]:\n",
    "        df[name] = df[name] + '_' + df[item].astype(str)\n",
    "    return df\n",
    "\n",
    "sub = cols_concat(sub, ['Store', 'Dept','Date'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "afcea9a9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:46:52.050639Z",
     "start_time": "2021-11-12T08:46:52.033280Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    }
   ],
   "source": [
    "del_cols = ['Store', 'Dept','Date']\n",
    "sub.drop(del_cols, axis=1, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "b86e7530",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:47:07.541266Z",
     "start_time": "2021-11-12T08:47:07.529985Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    }
   ],
   "source": [
    "sub.rename({'Store__Dept__Date': 'Id'}, axis=1, inplace=True)\n",
    "sub = sub[['Id', 'Weekly_Sales']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "c59b336a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:47:17.413668Z",
     "start_time": "2021-11-12T08:47:17.065254Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    }
   ],
   "source": [
    "sub.to_csv(\"./autogluon_sub_walmart_recruiting.csv\", index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "c43926aa",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-12T08:47:19.036955Z",
     "start_time": "2021-11-12T08:47:19.033422Z"
    }
   },
   "outputs": [],
   "source": [
    "# !zip -r autogluon_sub_kaggle_ventilator.csv.zip autogluon_sub_kaggle_ventilator.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b54628e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
